package com.acme.bankapp.domain.bank;

/**
 * Class for checking accounts with overdraft
 * @author alex
 */
public class CheckingAccount extends AbstractAccount {
	double overdraft;
	
	/**
	 * @param balance the balance
	 * @param overdraft the overdraft
	 */
	public CheckingAccount(double balance, double overdraft) {
		super(balance);
		if (overdraft > 0) {
			this.overdraft = overdraft;
		}
	}
	
	/**
	 * @param x the money
	 */
	public void withdraw(double x) {
		if (this.balance + this.overdraft >= x) {
			this.balance -= x;
		}
	}
	
	/**
	 * @return the maximum amount to withdraw
	 */
	public double maximumAmountToWithdraw() {
		return (this.balance + this.overdraft);
	}
	
	/**
	 * @return the sting presentation
	 */
	public String toString() {
		return "checking account, balance: " + this.balance + ", overdraft: " + this.overdraft;
	}
}
